#include common_scripts\utility;
#include maps\mp\_utility;
#include maps\mp\gametypes\_hud_util;
#include z_migliore\utility;

/*
self thread maps\mp\gametypes\_weapons::stowedWeaponsRefresh();
*/

init()
{
    precacheWeaponIcons();
    
    level waittill("connected");
    
    level.zItem_WeaponBox = weaponBox_Create();
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("m4_mp", true, "Medic", "weapon_m4carbine", undefined, undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("m4_gl_mp", true, "Assault", "weapon_m4carbine", "weapon_attachment_m203", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("m4_shotgun_mp", true, "Engineer", "weapon_m4carbine", "weapon_attachment_shotgun", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("m4_silencer_mp", true, "Recon", "weapon_m4carbine", "weapon_attachment_suppressor", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("m4_acog_gl_mp", true, "Assault", "weapon_m4carbine", "weapon_attachment_acog", "weapon_attachment_m203");
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("m4_eotech_gl_mp", true, "Assault", "weapon_m4carbine", "weapon_attachment_eotech", "weapon_attachment_m203");
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("m4_gl_reflex_mp", true, "Assault", "weapon_m4carbine", "weapon_attachment_m203", "weapon_attachment_reflex");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("famas_mp", true, "Medic", "weapon_famas", undefined, undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("famas_gl_mp", true, "Assault", "weapon_famas", "weapon_attachment_m203", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("famas_shotgun_mp", true, "Engineer", "weapon_famas", "weapon_attachment_shotgun", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("famas_silencer_mp", true, "Recon", "weapon_famas", "weapon_attachment_suppressor", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("famas_acog_gl_mp", true, "Assault", "weapon_famas", "weapon_attachment_acog", "weapon_attachment_m203");
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("famas_eotech_gl_mp", true, "Assault", "weapon_famas", "weapon_attachment_eotech", "weapon_attachment_m203");
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("famas_gl_reflex_mp", true, "Assault", "weapon_famas", "weapon_attachment_m203", "weapon_attachment_reflex");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("scar_mp", true, "Medic", "weapon_scar_h", undefined, undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("scar_gl_mp", true, "Assault", "weapon_scar_h", "weapon_attachment_m203", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("scar_shotgun_mp", true, "Engineer", "weapon_scar_h", "weapon_attachment_shotgun", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("scar_silencer_mp", true, "Recon", "weapon_scar_h", "weapon_attachment_suppressor", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("scar_acog_gl_mp", true, "Assault", "weapon_scar_h", "weapon_attachment_acog", "weapon_attachment_m203");
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("scar_eotech_gl_mp", true, "Assault", "weapon_scar_h", "weapon_attachment_eotech", "weapon_attachment_m203");
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("scar_gl_reflex_mp", true, "Assault", "weapon_scar_h", "weapon_attachment_m203", "weapon_attachment_reflex");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("tavor_mp", true, "Medic", "weapon_tavor", undefined, undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("tavor_gl_mp", true, "Assault", "weapon_tavor", "weapon_attachment_m203", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("tavor_shotgun_mp", true, "Engineer", "weapon_tavor", "weapon_attachment_shotgun", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("tavor_silencer_mp", true, "Recon", "weapon_tavor", "weapon_attachment_suppressor", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("tavor_acog_gl_mp", true, "Assault", "weapon_tavor", "weapon_attachment_acog", "weapon_attachment_m203");
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("tavor_eotech_gl_mp", true, "Assault", "weapon_tavor", "weapon_attachment_eotech", "weapon_attachment_m203");
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("tavor_gl_reflex_mp", true, "Assault", "weapon_tavor", "weapon_attachment_m203", "weapon_attachment_reflex");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("fal_mp", true, "Medic", "weapon_fnfal", undefined, undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("fal_gl_mp", true, "Assault", "weapon_fnfal", "weapon_attachment_m203", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("fal_shotgun_mp", true, "Engineer", "weapon_fnfal", "weapon_attachment_shotgun", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("fal_silencer_mp", true, "Recon", "weapon_fnfal", "weapon_attachment_suppressor", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("fal_acog_gl_mp", true, "Assault", "weapon_fnfal", "weapon_attachment_acog", "weapon_attachment_m203");
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("fal_eotech_gl_mp", true, "Assault", "weapon_fnfal", "weapon_attachment_eotech", "weapon_attachment_m203");
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("fal_gl_reflex_mp", true, "Assault", "weapon_fnfal", "weapon_attachment_m203", "weapon_attachment_reflex");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("m16_mp", true, "Medic", "weapon_m16a4", undefined, undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("m16_gl_mp", true, "Assault", "weapon_m16a4", "weapon_attachment_m203", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("m16_shotgun_mp", true, "Engineer", "weapon_m16a4", "weapon_attachment_shotgun", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("m16_silencer_mp", true, "Recon", "weapon_m16a4", "weapon_attachment_suppressor", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("m16_acog_gl_mp", true, "Assault", "weapon_m16a4", "weapon_attachment_acog", "weapon_attachment_m203");
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("m16_eotech_gl_mp", true, "Assault", "weapon_m16a4", "weapon_attachment_eotech", "weapon_attachment_m203");
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("m16_gl_reflex_mp", true, "Assault", "weapon_m16a4", "weapon_attachment_m203", "weapon_attachment_reflex");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("masada_mp", true, "Medic", "weapon_masada", undefined, undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("masada_gl_mp", true, "Assault", "weapon_masada", "weapon_attachment_m203", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("masada_shotgun_mp", true, "Engineer", "weapon_masada", "weapon_attachment_shotgun", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("masada_silencer_mp", true, "Recon", "weapon_masada", "weapon_attachment_suppressor", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("masada_acog_gl_mp", true, "Assault", "weapon_masada", "weapon_attachment_acog", "weapon_attachment_m203");
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("masada_eotech_gl_mp", true, "Assault", "weapon_masada", "weapon_attachment_eotech", "weapon_attachment_m203");
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("masada_gl_reflex_mp", true, "Assault", "weapon_masada", "weapon_attachment_m203", "weapon_attachment_reflex");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("fn2000_mp", true, "Medic", "weapon_fn2000", undefined, undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("fn2000_gl_mp", true, "Assault", "weapon_fn2000", "weapon_attachment_m203", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("fn2000_shotgun_mp", true, "Engineer", "weapon_fn2000", "weapon_attachment_shotgun", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("fn2000_silencer_mp", true, "Recon", "weapon_fn2000", "weapon_attachment_suppressor", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("fn2000_acog_gl_mp", true, "Assault", "weapon_fn2000", "weapon_attachment_acog", "weapon_attachment_m203");
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("fn2000_eotech_gl_mp", true, "Assault", "weapon_fn2000", "weapon_attachment_eotech", "weapon_attachment_m203");
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("fn2000_gl_reflex_mp", true, "Assault", "weapon_fn2000", "weapon_attachment_m203", "weapon_attachment_reflex");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("ak47_mp", true, "Medic", "weapon_ak47", undefined, undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("ak47_gl_mp", true, "Assault", "weapon_ak47", "weapon_attachment_m203", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("ak47_shotgun_mp", true, "Engineer", "weapon_ak47", "weapon_attachment_shotgun", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("ak47_silencer_mp", true, "Recon", "weapon_ak47", "weapon_attachment_suppressor", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("ak47_acog_gl_mp", true, "Assault", "weapon_ak47", "weapon_attachment_acog", "weapon_attachment_m203");
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("ak47_eotech_gl_mp", true, "Assault", "weapon_ak47", "weapon_attachment_eotech", "weapon_attachment_m203");
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("ak47_gl_reflex_mp", true, "Assault", "weapon_ak47", "weapon_attachment_m203", "weapon_attachment_reflex");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("mp5k_mp", true, "AA Specialist", "weapon_mp5k", undefined, undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("mp5k_eotech_mp", true, "AA Specialist", "weapon_mp5k", "weapon_attachment_eotech", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("mp5k_reflex_mp", true, "AA Specialist", "weapon_mp5k", "weapon_attachment_reflex", undefined);
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("ump45_mp", true, "AA Specialist", "weapon_ump45", undefined, undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("ump45_eotech_mp", true, "AA Specialist", "weapon_ump45", "weapon_attachment_eotech", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("ump45_reflex_mp", true, "AA Specialist", "weapon_ump45", "weapon_attachment_reflex", undefined);
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("kriss_mp", true, "AA Specialist", "weapon_kriss", undefined, undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("kriss_eotech_mp", true, "AA Specialist", "weapon_kriss", "weapon_attachment_eotech", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("kriss_reflex_mp", true, "AA Specialist", "weapon_kriss", "weapon_attachment_reflex", undefined);
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("p90_mp", true, "AA Specialist", "weapon_p90", undefined, undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("p90_eotech_mp", true, "AA Specialist", "weapon_p90", "weapon_attachment_eotech", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("p90_reflex_mp", true, "AA Specialist", "weapon_p90", "weapon_attachment_reflex", undefined);
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("uzi_mp", true, "AA Specialist", "weapon_mini_uzi", undefined, undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("uzi_eotech_mp", true, "AA Specialist", "weapon_mini_uzi", "weapon_attachment_eotech", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("uzi_reflex_mp", true, "AA Specialist", "weapon_mini_uzi", "weapon_attachment_reflex", undefined);
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("sa80_grip_xmags_mp", true, "Heavy", "weapon_sa80", "weapon_attachment_grip", "weapon_attachment_xmags");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("rpd_grip_xmags_mp", true, "Heavy", "weapon_rpd", "weapon_attachment_grip", "weapon_attachment_xmags");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("mg4_grip_xmags_mp", true, "Heavy", "weapon_mg4", "weapon_attachment_grip", "weapon_attachment_xmags");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("aug_grip_xmags_mp", true, "Heavy", "weapon_aug", "weapon_attachment_grip", "weapon_attachment_xmags");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("m240_grip_xmags_mp", true, "Heavy", "weapon_m240", "weapon_attachment_grip", "weapon_attachment_xmags");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("cheytac_fmj_mp", true, "Recon", "weapon_cheytac", "weapon_attachment_fmj", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("cheytac_fmj_thermal_mp", true, "Recon", "weapon_cheytac", "weapon_attachment_fmj", "weapon_attachment_thermal");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("barrett_fmj_mp", true, "Recon", "weapon_barrett50cal", "weapon_attachment_fmj", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("barrett_fmj_thermal_mp", true, "Recon", "weapon_barrett50cal", "weapon_attachment_fmj", "weapon_attachment_thermal");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("wa2000_fmj_mp", true, "Recon", "weapon_wa2000", "weapon_attachment_fmj", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("wa2000_silencer_mp", true, "Recon", "weapon_wa2000", "weapon_attachment_suppressor", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("wa2000_fmj_thermal_mp", true, "Recon", "weapon_wa2000", "weapon_attachment_fmj", "weapon_attachment_thermal");
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("wa2000_silencer_thermal_mp", true, "Recon", "weapon_wa2000", "weapon_attachment_suppressor", "weapon_attachment_thermal");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("m21_fmj_mp", true, "Recon", "weapon_m14ebr", "weapon_attachment_fmj", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("m21_silencer_mp", true, "Recon", "weapon_m14ebr", "weapon_attachment_suppressor", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("m21_fmj_thermal_mp", true, "Recon", "weapon_m14ebr", "weapon_attachment_fmj", "weapon_attachment_thermal");
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("m21_silencer_thermal_mp", true, "Recon", "weapon_m14ebr", "weapon_attachment_suppressor", "weapon_attachment_thermal");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("pp2000_xmags_mp", true, "AA Specialist", "weapon_pp2000", "weapon_attachment_xmags", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("pp2000_eotech_xmags_mp", true, "AA Specialist", "weapon_pp2000", "weapon_attachment_eotech", "weapon_attachment_xmags");
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("pp2000_reflex_xmags_mp", true, "AA Specialist", "weapon_pp2000", "weapon_attachment_reflex", "weapon_attachment_xmags");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("beretta393_xmags_mp", true, "AA Specialist", "weapon_beretta393", "weapon_attachment_xmags", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("beretta393_eotech_xmags_mp", true, "AA Specialist", "weapon_beretta393", "weapon_attachment_eotech", "weapon_attachment_xmags");
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("beretta393_reflex_xmags_mp", true, "AA Specialist", "weapon_beretta393", "weapon_attachment_reflex", "weapon_attachment_xmags");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("tmp_xmags_mp", true, "AA Specialist", "weapon_tmp", "weapon_attachment_xmags", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("tmp_eotech_xmags_mp", true, "AA Specialist", "weapon_tmp", "weapon_attachment_eotech", "weapon_attachment_xmags");
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("tmp_reflex_xmags_mp", true, "AA Specialist", "weapon_tmp", "weapon_attachment_reflex", "weapon_attachment_xmags");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("spas12_mp", true, "Engineer", "weapon_spas12", undefined, undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("spas12_eotech_mp", true, "Engineer", "weapon_spas12", "weapon_attachment_eotech", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("spas12_grip_mp", true, "Engineer", "weapon_spas12", "weapon_attachment_grip", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("spas12_reflex_mp", true, "Engineer", "weapon_spas12", "weapon_attachment_reflex", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("spas12_eotech_grip_mp", true, "Engineer", "weapon_spas12", "weapon_attachment_eotech", "weapon_attachment_grip");
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("spas12_grip_reflex_mp", true, "Engineer", "weapon_spas12", "weapon_attachment_grip", "weapon_attachment_reflex");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("aa12_xmags_mp", true, "Engineer", "weapon_aa12", "weapon_attachment_xmags", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("aa12_grip_xmags_mp", true, "Engineer", "weapon_aa12", "weapon_attachment_grip", "weapon_attachment_xmags");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("striker_mp", true, "Engineer", "weapon_striker", undefined, undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("striker_eotech_mp", true, "Engineer", "weapon_striker", "weapon_attachment_eotech", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("striker_grip_mp", true, "Engineer", "weapon_striker", "weapon_attachment_grip", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("striker_reflex_mp", true, "Engineer", "weapon_striker", "weapon_attachment_reflex", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("striker_eotech_grip_mp", true, "Engineer", "weapon_striker", "weapon_attachment_eotech", "weapon_attachment_grip");
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("striker_grip_reflex_mp", true, "Engineer", "weapon_striker", "weapon_attachment_grip", "weapon_attachment_reflex");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("m1014_xmags_mp", true, "Engineer", "weapon_m1014", "weapon_attachment_xmags", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("m1014_grip_xmags_mp", true, "Engineer", "weapon_m1014", "weapon_attachment_grip", "weapon_attachment_xmags");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("usp_mp", false, "AA Specialist;Assault;Engineer;Heavy;Medic", "weapon_usp_45", undefined, undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("usp_silencer_mp", false, "Recon", "weapon_usp_45", "weapon_attachment_suppressor", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("usp_tactical_mp", false, "Recon", "weapon_usp_45", "weapon_attachment_tactical", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("usp_silencer_tactical_mp", false, "Recon", "weapon_usp_45", "weapon_attachment_suppressor", "weapon_attachment_tactical");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("coltanaconda_fmj_mp", false, "AA Specialist;Assault;Engineer;Heavy;Medic", "weapon_colt_anaconda", "weapon_attachment_fmj", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("coltanaconda_fmj_tactical_mp", false, "Recon", "weapon_colt_anaconda", "weapon_attachment_fmj", "weapon_attachment_tactical");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("beretta_mp", false, "AA Specialist;Assault;Engineer;Heavy;Medic", "weapon_m9beretta", undefined, undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("beretta_silencer_mp", false, "Recon", "weapon_m9beretta", "weapon_attachment_suppressor", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("beretta_tactical_mp", false, "Recon", "weapon_m9beretta", "weapon_attachment_tactical", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("beretta_silencer_tactical_mp", false, "Recon", "weapon_m9beretta", "weapon_attachment_suppressor", "weapon_attachment_tactical");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("glock_xmags_mp", false, "AA Specialist", "weapon_glock", "weapon_attachment_xmags", undefined);
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("glock_eotech_xmags_mp", false, "AA Specialist", "weapon_glock", "weapon_attachment_eotech", "weapon_attachment_xmags");
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("glock_reflex_xmags_mp", false, "AA Specialist", "weapon_glock", "weapon_attachment_reflex", "weapon_attachment_xmags");
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("at4_mp", false, "AA Specialist", "weapon_at4", undefined, undefined);
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("stinger_mp", false, "AA Specialist", "weapon_stinger", undefined, undefined);
    
    level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("javelin_mp", false, "AA Specialist", "weapon_javelin", undefined, undefined);
    
    
    // level.zItem_WeaponBox.list[level.zItem_WeaponBox.list.size] = weaponBox_CreateItem("Weapon", true/false, "Class", "weapon_icon", undefined, undefined);
    // AA Specialist;Assault;Engineer;Heavy;Medic;Recon
}

weaponBox_Create()
{
    weaponbox = spawn("script_model", level.zMap_AttackersWeaponBoxOrigin);
    weaponbox.angles = level.zMap_AttackersWeaponBoxAngles;
    weaponbox.team = level.zCfg_AttackersTeam;
    weaponbox setModel("com_plasticcase_friendly");
    weaponbox cloneBrushmodelToScriptmodel(level.airDropCrateCollision);
    
    weaponbox.list = []; // array init for the weapon list
    
    weaponbox.decor = [];
    weaponbox.decor[0] = spawn("script_model", level.zMap_AttackersWeaponBoxOrigin);
    weaponbox.decor[0] setModel("weapon_magpul_masada_orange_fall");
    weaponbox.decor[0] z_WeaponModelManageTags("masada_reflex_silencer_mp", "tag_heartbeat");
    weaponbox.decor[0] linkTo(weaponbox, "tag_origin", (10, -8, 15), (0, 20, 90)); // (x,z,y) (z,y,x)
    
    weaponbox.decor[1] = spawn("script_model", level.zMap_AttackersWeaponBoxOrigin);
    weaponbox.decor[1] setModel("weapon_steyr_lmg");
    weaponbox.decor[1] z_WeaponModelManageTags("aug_grip_mp", "tag_steyr_scope");
    weaponbox.decor[1] linkTo(weaponbox, "tag_origin", (0, 5, 22), (0, 10, 5));
    
    weaponbox.decor[2] = spawn("script_model", level.zMap_AttackersWeaponBoxOrigin);
    weaponbox.decor[2] setModel("weapon_m82");
    weaponbox.decor[2] z_WeaponModelManageTags("barrett_mp");
    weaponbox.decor[2] linkTo(weaponbox, "tag_origin", (-30, 3, 7), (-80, 0, 90));
    
    weaponbox physicsLaunchServer((0, 0, 0), (0, 0, 0));
    
    weaponbox waittill("physics_finished");
    
    // todo: some lights
    
    weaponbox.trigger = spawn("trigger_radius", weaponbox.origin + (0, 0, -25), 0, 100, 150);
    
    weaponbox thread weaponBox_Logic();
    
    return weaponbox;
}

weaponBox_CreateItem(new_weapon, is_primary, available_classes, main_icon, attach1_icon, attach2_icon)
{
    item = spawnStruct();
    
    item.weapon = new_weapon;
    item.available = available_classes;
    item.primary = is_primary;
    
    item.icon = [];
    item.icon[0] = main_icon;
    item.icon[1] = attach1_icon;
    item.icon[2] = attach2_icon;
    
    return item;
}

weaponBox_Logic()
{
    self endon("death");
    level endon("game_ended");
    
    for(;;) {
        self.trigger waittill("trigger", entity);
        
        foreach(player in level.players) {
            if(!player isTouching(self.trigger))
                continue;
            
            if(player.team != level.zCfg_AttackersTeam)
                continue;
            
            if(player.zMenu_UsingClassMenu || player.zMenu_UsingWeaponMenu || player.zMenu_UsingWeaponMenuDelay)
                continue;
            
            if(!player isOnGround() || !player useButtonPressed())
                continue;
            
            self thread weaponBox_PlayerUsed(player);
        }
        
        wait(0.05);
    }
}

weaponBox_PlayerUsed(player)
{
    if(player.zMenu_UsingWeaponMenu)
        return;
    
    player.zMenu_UsingWeaponMenu = true;
    
    player endon("death");
    player endon("disconnect");
    self endon("death");
    
    selecting = true;
    tempWanted = 0;
    
    if(player.zClass_Current == -1) {
        wait(1.0);
        player.zMenu_UsingWeaponMenu = false;
        
        player iPrintLnBold("You have to select a class first!");
    } else {
        player freezeControlsWrapper(true);
        
        // switch a menu weapon to available one
        if(!weaponBox_PlayerCanUseWeapon(player, player.zWeapon_Wanted)) {
            tempWanted = player.zWeapon_Wanted;
            player.zWeapon_Wanted = weaponBox_GetPrevAvailable(player);
            
            if(tempWanted == player.zWeapon_Wanted)
                player.zWeapon_Wanted = weaponBox_GetNextAvailable(player);
        }
        
        player z_migliore\_menu::weaponMenu_Update(self.list[player.zWeapon_Wanted].icon[0], self.list[player.zWeapon_Wanted].icon[1], self.list[player.zWeapon_Wanted].icon[2]);
        //player z_migliore\_menu::weaponMenu_Update2(self.list[player.zWeapon_Wanted].icon);
        
        while(selecting) {
            result = player waittill_any_return("zkey_forward", "zkey_back", "zkey_activate");
            
            if(result == "zkey_forward") {
                tempWanted = player.zWeapon_Wanted;
                player.zWeapon_Wanted = weaponBox_GetPrevAvailable(player);
                
                if(tempWanted != player.zWeapon_Wanted) {
                    player z_migliore\_menu::weaponMenu_Update(self.list[player.zWeapon_Wanted].icon[0], self.list[player.zWeapon_Wanted].icon[1], self.list[player.zWeapon_Wanted].icon[2]);
                    //player z_migliore\_menu::weaponMenu_Update2(self.list[player.zWeapon_Wanted].icon);
                }
            } else if(result == "zkey_back") {
                tempWanted = player.zWeapon_Wanted;
                player.zWeapon_Wanted = weaponBox_GetNextAvailable(player);
                
                if(tempWanted != player.zWeapon_Wanted) {
                    player z_migliore\_menu::weaponMenu_Update(self.list[player.zWeapon_Wanted].icon[0], self.list[player.zWeapon_Wanted].icon[1], self.list[player.zWeapon_Wanted].icon[2]);
                    //player z_migliore\_menu::weaponMenu_Update2(self.list[player.zWeapon_Wanted].icon);
                }
            } else if(result == "zkey_activate") {
                if(weaponBox_PlayerCanUseWeapon(player, player.zWeapon_Wanted)) { // доп проверка - скорее всего можно убрать
                    //player takeWeapon(player.zWeapon_Primary);
                    //player takeWeapon(player.zWeapon_Secondary);
                    
                    player notify("zweapons_changed");
                    
                    primaryWeapons = player getWeaponsListPrimaries();
                    foreach(primary in primaryWeapons)
                        player takeWeapon(primary);
                    
                    if(level.zItem_WeaponBox.list[player.zWeapon_Wanted].primary) {
                        player.zClass_PrimaryWeapon = level.zItem_WeaponBox.list[player.zWeapon_Wanted].weapon;
                        
                        player.pers["primaryWeapon"] = player.zClass_PrimaryWeapon;
                        player.primaryWeapon = player.zClass_PrimaryWeapon;
                    } else {
                        player.zClass_SecondaryWeapon = level.zItem_WeaponBox.list[player.zWeapon_Wanted].weapon;
                        
                        player.secondaryWeapon = player.zClass_SecondaryWeapon;
                    }
                    
                    player z_GiveWeapons();
                    player thread maps\mp\gametypes\_weapons::stowedWeaponsRefresh();
                    
                    selecting = false;
                    
                    player z_migliore\_menu::weaponMenu_Alpha(0, 0, 0);
                } else {
                    player iPrintLnBold("This weapon is not available for you!");
                }
            }
        }
        
        self thread weaponBox_PlayerDelay(player, 2.0); // используется проверка нажатия кнопки, так что даем время на то, чтобы отпустить
        
        player.zMenu_UsingWeaponMenu = false;
        player freezeControlsWrapper(false);
    }
}

weaponBox_PlayerCanUseWeapon(player, wanted_weapon_id)
{
    if(player.zClass_Current == -1)
        return false;
    
    if(isSubStr(level.zItem_WeaponBox.list[wanted_weapon_id].available, level.zClass_List[player.zClass_Current].name))
        return true;
    
    return false;
}

weaponBox_PlayerDelay(player, delay)
{
    player endon("disconnect");
    
    player.zMenu_UsingWeaponMenuDelay = true;
    wait(delay);
    player.zMenu_UsingWeaponMenuDelay = false;
}

weaponBox_GetNextAvailable(player)
{
    for(i = player.zWeapon_Wanted+1; i < level.zItem_WeaponBox.list.size; i++) {
        if(weaponBox_PlayerCanUseWeapon(player, i))
            return i;
    }
    
    return player.zWeapon_Wanted;
}

weaponBox_GetPrevAvailable(player)
{
    for(i = player.zWeapon_Wanted-1; i >= 0; i--) {
        if(weaponBox_PlayerCanUseWeapon(player, i))
            return i;
    }
    
    return player.zWeapon_Wanted;
}

/*weaponBox_MenuUpdate(player)
{
    player.zMenu_WeaponSelect[0] setIconShader(self.list[player.zWeapon_Wanted].icon[0]);
    player.zMenu_WeaponSelect[0] setIconSize(75, 38);
    
    if(isDefined(self.list[player.zWeapon_Wanted].icon[1])) { // there is icon for attach1
        player.zMenu_WeaponSelect[1] setIconShader(self.list[player.zWeapon_Wanted].icon[1]);
        player.zMenu_WeaponSelect[1] setIconSize(32, 32);
        
        if(isDefined(self.list[player.zWeapon_Wanted].icon[2])) { // there is icon for attach2
            player.zMenu_WeaponSelect[2] setIconShader(self.list[player.zWeapon_Wanted].icon[2]);
            player.zMenu_WeaponSelect[2] setIconSize(32, 32);
            
            player z_migliore\_menu::weaponMenu_Alpha(1, 1, 1);
        } else {
            player z_migliore\_menu::weaponMenu_Alpha(1, 1, 0);
        }
    } else {
        player z_migliore\_menu::weaponMenu_Alpha(1, 0, 0);
    }
}*/

precacheWeaponIcons()
{
    // assault rifles
    precacheShader("weapon_m4carbine");
    precacheShader("weapon_famas");
    precacheShader("weapon_scar_h");
    precacheShader("weapon_tavor");
    precacheShader("weapon_fnfal");
    precacheShader("weapon_m16a4");
    precacheShader("weapon_masada");
    precacheShader("weapon_fn2000");
    precacheShader("weapon_ak47");
    
    
    // sub-machine-guns
    precacheShader("weapon_mp5k");
    precacheShader("weapon_ump45");
    precacheShader("weapon_kriss");
    precacheShader("weapon_p90");
    precacheShader("weapon_mini_uzi");
    
    
    // light-machine-guns
    precacheShader("weapon_sa80");
    precacheShader("weapon_rpd");
    precacheShader("weapon_mg4");
    precacheShader("weapon_aug");
    precacheShader("weapon_m240");
    
    
    // sniper rifles
    precacheShader("weapon_cheytac");
    precacheShader("weapon_barrett50cal");
    precacheShader("weapon_wa2000");
    precacheShader("weapon_m14ebr");
    
    
    // shotguns
    precacheShader("weapon_spas12");
    precacheShader("weapon_aa12");
    precacheShader("weapon_striker");
    precacheShader("weapon_m1014");
    
    
    // auto pistols
    precacheShader("weapon_pp2000");
    precacheShader("weapon_beretta393");
    precacheShader("weapon_tmp");
    
    
    // handguns
    precacheShader("weapon_usp_45");
    precacheShader("weapon_colt_anaconda");
    precacheShader("weapon_m9beretta");
    precacheShader("weapon_glock");
    
    
    // rocket launchers
    precacheShader("weapon_at4");
    precacheShader("weapon_stinger");
    precacheShader("weapon_javelin");
    
    
    // attachments
    precacheShader("weapon_attachment_acog");
    precacheShader("weapon_attachment_akimbo");
    precacheShader("weapon_attachment_eotech");
    precacheShader("weapon_attachment_fmj");
    precacheShader("weapon_attachment_grip");
    precacheShader("weapon_attachment_heartbeat");
    precacheShader("weapon_attachment_m203");
    precacheShader("weapon_attachment_reflex");
    precacheShader("weapon_attachment_rof");
    precacheShader("weapon_attachment_shotgun");
    precacheShader("weapon_attachment_suppressor");
    precacheShader("weapon_attachment_tactical");
    precacheShader("weapon_attachment_thermal");
    precacheShader("weapon_attachment_xmags");
}

